home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / aprompt.zip / APROMPT.PAS < prev   
Pascal/Delphi Source File  |  1990-12-22  |  7KB  |  179 lines

  1.  
  2. (********************************************************************
  3. Author: Chuck Dearbeck - THE BAD ATTITUDE BBS!  814-459-2116
  4.  
  5. With help from the ANSI CRT replacement Unit from Rick Housh ANSICRT.PAS,
  6. and of course I'm still borrowing...stealing... whatever you want to call
  7. it ... from source code Mike Woltz the author of SpitFire BBS has put out.
  8. The Unit (ANSICRT) isn't included in this ZIP file to make it smaller and
  9. also so a person wouldn't already have it and download it twice. It is
  10. needed to compile unless you want to do everything yourself.  If you can't
  11. find it you can download it from the above BBS.  I read in a computer mag
  12. article Jim Button considers a lot of the shareware available HECKWARE.
  13. Somebody writes something... figures 'WHAT THE HECK' I'll give it a price and
  14. maybe some dummy will send me money even though it doesn't do much.  I agree
  15. with him so I figure this could be considered What-The-Heckware too.  The
  16. difference though is I figure 'What the Heck, even though it doesn't do much,
  17. it is free and the source code (however amateurish) comes with it. But, it
  18. could have some slight value to someone who has just started programming, so
  19. if thats you I hope it helps a little.  I can think of some improvements that
  20. could be made in how it works... you could give the user the option of how
  21. they want their prompts, whether they even want the time in it, more colors,
  22. two-line prompts, prompts with the date... etc... but ... WHAT THE HECK!
  23.  
  24. ********************************************************************)
  25. Program Aprompt;
  26.  
  27.       Uses Dos, Anscrt;  (* Turbo Pascal units used *)
  28.  
  29.  
  30.   Var
  31.     Choice     : String;
  32.  
  33.  (*------------------------------*)
  34.  Procedure Find_Config;
  35.  (*------------------------------*)
  36.   Var
  37.         Config : Text;
  38.        Conline : String;
  39.    Config_Line : Boolean;
  40.              i : byte;
  41.  
  42.   Begin
  43.     Config_Line := False;
  44.      Assign(Config,'C:\CONFIG.SYS');   (* open To read *)
  45.        {$I-}Reset(Config);{$I+}
  46.          If IOResult <> 0 Then       (* couldn't find it? *)
  47.          Begin
  48.         Writeln;
  49.        Writeln(^G,'CONFIG.SYS File Not Found!');
  50.        Halt;                     (* Config.sys not found so halt program *)
  51.       end;
  52.  
  53.     Repeat
  54.      ReadLn(Config,Conline);       (* config.sys was found so read it *)
  55.        For i := 1 To Length(Conline) Do    (* make line upper case *)
  56.        Conline[i] := UpCase(Conline[i]);
  57.     If POS('ANSI.SYS',Conline) <> 0 Then  (* does it say ANSI.SYS anywhere? *)
  58.       Config_Line := True;                (* yes it does *)
  59.      Until EOF(Config);
  60.  
  61.     If Config_Line = False Then        (* no ANSI.SYS statement so ... *)
  62.      Begin;
  63.       WriteLn(^g,'You Don''t Have DEVICE=ANSI.SYS In Your CONFIG.SYS File!');
  64.        Halt;
  65.      end;
  66.       Close(config);
  67.      end;
  68.  
  69.  (*------------------------------*)
  70.   Procedure Auto_Write;             (* they chose to change their prompt *)
  71.  (*------------------------------*)
  72.   Var
  73.    Autoprom,
  74.        Temp  : Text;
  75.        Pick  : Char;
  76.           i  : Byte;
  77.    Autoline  : String;
  78.       Found  : Boolean;
  79.  
  80.    Begin;
  81.     Found := False;
  82.       Assign(Autoprom,'c:\AutoExec.BAT');  (* open To read *)
  83.        {$I-}Reset(Autoprom);{$I+}
  84.         If IOResult <> 0 Then   (* no AUTOEXEC.BAT file was found *)
  85.           Begin
  86.          Writeln;
  87.         Writeln(^G,'AUTOEXEC.BAT Not Found!');
  88.        Halt;
  89.       end;
  90.  
  91.     Assign(Temp,'c:\AutoTemp.BAT');  (* open temporary file to write *)
  92.      {$I-}Rewrite(Temp);{$I+}
  93.        Append(Temp);
  94.  
  95.     Repeat
  96.      ReadLn(Autoprom,AutoLine);     (* read a line from the AUTOEXEC.BAT *)
  97.       For i := 1 To Length(autoLine) Do
  98.        Autoline[i] := UpCase(AutoLine[i]);    (* make it upper case *)
  99.         If POS('PROMPT',AutoLine) <> 0 Then   (* check for the word PROMPT *)
  100.       Begin
  101.        AutoLine := Choice;    (* if its found change line to their choice *)
  102.         Found := True;
  103.       end;
  104.        Writeln(Temp,AutoLine);  (* write the line to temporary file *)
  105.          Until EOF(Autoprom);
  106.           Close(Autoprom);
  107.         If Not Found Then        (* the word PROMPT wasn't found *)
  108.          Writeln(Temp,Choice);   (* so put their choice in anyways *)
  109.      Close(Temp);
  110.       Erase(Autoprom);                 (* erase old AUTOEXEC.BAT *)
  111.        Rename(Temp,'C:\AUTOEXEC.BAT'); (* make temporary file the AUTOEXEC *)
  112.         Writeln;
  113.        Writeln;
  114.       TextColor(10); Writeln('Big deal huh?');   (* WHAT THE HECK! *)
  115.      Writeln;
  116.    TextColor(15); Write('Do you want to Reboot for your new prompt to take effect! ');
  117.    TextColor(14); Write('[y/n] ');
  118.    Pick := Upcase(Readkey);  (* read the keypress, make upper case *)
  119.     if Pick='Y' Then
  120.      Begin                 (* yes, they want to reboot *)
  121.       MEMW[$0040:$0072] := $1234;
  122.       INLINE($EA/$00/$00/$FF/$FF);
  123.        end;
  124.      end;
  125.  
  126.  (*-------------------------------
  127.            Main Program
  128.  (*-------------------------------*)
  129.  Var
  130.    Which : Char;
  131.     Done : Boolean;
  132.  
  133.  Begin;
  134.     Done := False;
  135.      Repeat
  136.       Clrscr;
  137.     Find_Config;
  138.      Writeln;
  139.       TextColor(13); Write('  ANSI ');
  140.       TextColor(11); Write('Color ');
  141.       TextColor(10); Write('Prompt ');
  142.       TextColor(14); Writeln('v1.0 ');
  143.     Writeln;
  144.        TextColor(15); Write('  What-The-Heckware From - ');
  145.      TextColor(14); Writeln(' The Bad Attitude BBS! ');
  146.     TextColor(11); Writeln('                                  814-459-2116');
  147.       Writeln;
  148.       Writeln;
  149.      TextColor(9); Writeln('    <1>... Like this? - 12:06 C:\DOS>');
  150.      TextColor(10); Writeln('    <2>... Like this? - 12:06 C:\DOS>');
  151.      TextColor(11); Writeln('    <3>... Like this? - 12:06 C:\DOS>');
  152.      TextColor(12); Writeln('    <4>... Like this? - 12:06 C:\DOS>');
  153.      TextColor(13); Writeln('    <5>... Like this? - 12:06 C:\DOS>');
  154.      TextColor(14); Writeln('    <6>... Like this? - 12:06 C:\DOS>');
  155.      TextColor(15); Writeln('    <7>... Quit!');
  156.        Writeln;
  157.      TextColor(15);Write('       Pick the color of prompt you like ... ');
  158.       Repeat
  159.        Which := ReadKey;
  160.         Until  Which In ['1','2','3','4','5','6','7'];
  161.          Write(Which);
  162.       Case Which Of
  163.         '1' : Choice := 'PROMPT $e[0;1;34m$t$H$H$H$H$H$H $P$G $e[37m';
  164.         '2' : Choice := 'PROMPT $e[0;1;32m$t$H$H$H$H$H$H $P$G $e[37m';
  165.         '3' : Choice := 'PROMPT $e[0;1;36m$t$H$H$H$H$H$H $P$G $e[37m';
  166.         '4' : Choice := 'PROMPT $e[0;1;31m$t$H$H$H$H$H$H $P$G $e[37m';
  167.         '5' : Choice := 'PROMPT $e[0;1;35m$t$H$H$H$H$H$H $P$G $e[37m';
  168.         '6' : Choice := 'PROMPT $e[0;1;33m$t$H$H$H$H$H$H $P$G $e[37m';
  169.         '7' : Done := True;  (* they want to quit *)
  170.       end;
  171.  
  172.     If Not Done Then    (* they pick a prompt from the list so... *)
  173.      Auto_Write;        (* write the file                         *)
  174.       Until Done;
  175.      ClrScr;
  176.     Writeln;
  177.     Writeln;
  178.    END.
  179.